﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToRTR.CApExportToRTRLocationsValidator
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.ExportToRTR.Resources;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ExportToRTR{

internal class CApExportToRTRLocationsValidator : CApExportToRTRBaseValidator
{
  public override bool IsValidObject(ITxObject obj, out string errorMessage)
  {
    bool flag = false;
    errorMessage = (string) null;
    if (obj is ITxObjectCollection objectCollection && objectCollection is ITxOperation)
    {
      TxObjectList allDescendants = (obj as ITxObjectCollection).GetAllDescendants((ITxTypeFilter) new TxTypeFilter(typeof (ITxRoboticLocationOperation)));
      if (((Collection<ITxObject>) allDescendants).Count == 0)
        errorMessage = ExportToRTRStringTable.VALIDATOR_NO_LOCATIONS_ERROR;
      else if (!((IEnumerable<ITxObject>) allDescendants).Any<ITxObject>((Func<ITxObject, bool>) (x => CApExportToRTRUtils.HasAssignedRobot(x as ITxRoboticLocationOperation))))
        errorMessage = ExportToRTRStringTable.VALIDATOR_NO_ROBOT_ASSIGNED_ERROR;
      else
        flag = true;
    }
    else
      errorMessage = ExportToRTRStringTable.VALIDATOR_ONLY_ROBOTIC_OPERATION_ERROR;
    return flag;
  }
}
